type DeepPromiseValueType<P extends Promise<unknown>> = P extends Promise<infer ValueType>
  ? ValueType extends Promise<unknown>
    ? DeepPromiseValueType<ValueType>
    : ValueType
  : never;

type PPP = Promise<Promise<Record<string, any>>>;
type Result38 = DeepPromiseValueType<PPP>;

type PromiseValueType<T> = T extends Promise<infer ValueType> ? PromiseValueType<ValueType> : T;

type Result39 = PromiseValueType<PPP>;

type ReverseTuple<T extends unknown[]> = T extends [infer Fst, ...infer Rest]
  ? [...ReverseTuple<Rest>, Fst]
  : T;

type Result40 = ReverseTuple<[1, 2, 3, 4]>;

type Result41 = ReverseTuple<Tuple>;

type Includes<Arr extends unknown[], FindItem> = Arr extends [infer Fst, ...infer Rest]
  ? IsEq<Fst, FindItem> extends true
    ? true
    : Includes<Rest, FindItem>
  : false;

type Result42 = Includes<Tuple, 4>;

type RemoveItem<Arr extends unknown[], Item, Result extends unknown[]> = Arr extends [
  infer Fst,
  ...infer Rest,
]
  ? IsEqual<Fst, Item> extends true
    ? RemoveItem<Rest, Item, Result>
    : RemoveItem<Rest, Item, [...Result, Fst]>
  : Result;

type Result43 = RemoveItem<Tuple, 2, []>;

type Remove<Arr extends unknown[], Item> = Arr extends [infer X, ...infer Rest]
  ? IsEqual<X, Item> extends true
    ? Remove<Rest, Item>
    : [X, ...Remove<Rest, Item>]
  : [];

type Result44 = Remove<[1, 2, 3], 2>;

type IsEqual<A, B> = (A extends B ? true : false) & (B extends A ? true : false);

type Length<T extends unknown[]> = T extends { length: infer L } ? L : never;

type BuildArray<L extends number, E = unknown, Arr extends unknown[] = []> = Length<Arr> extends L
  ? Arr
  : BuildArray<L, E, [...Arr, E]>;

type Result45 = BuildArray<10, 1, []>;

type Replace<
  Str extends string,
  From extends string,
  To extends string,
> = Str extends `${infer Prefix}${From}${infer Suffix}` ? `${Prefix}${To}${Suffix}` : Str;

type Result46 = Replace<'abc?', '?', 'def'>;

type ReplaceAll<
  Str extends string,
  From extends string,
  To extends string,
> = Str extends `${infer Left}${From}${infer Right}`
  ? `${Left}${To}${ReplaceAll<Right, From, To>}`
  : Str;

type Result47 = ReplaceAll<'abcabcabc', 'a', 'd'>;

type StrToUnion<Str extends string> = Str extends `${infer Fst}${infer Rest}`
  ? Fst | StrToUnion<Rest>
  : never;

type Result48 = StrToUnion<'boolean'>;

type ReverseStr<Str extends string> = Str extends `${infer Fst}${infer Rest}`
  ? `${ReverseStr<Rest>}${Fst}`
  : Str;

type Result49 = ReverseStr<'123'>;

type DeepReadonly<T extends Record<string, any>> = T extends any
  ? {
      readonly [K in keyof T]: T[K] extends object
        ? T[K] extends Function
          ? T[K]
          : DeepReadonly<T[K]>
        : T[K];
    }
  : never;

const o = {
  a: {
    b: {
      c: () => '1',
      d: {
        e: {
          f: '2',
        },
      },
    },
  },
};
type Result50 = DeepReadonly<typeof o>;
